#include <iostream>

using namespace std;

class A
{
public:
    A(int a = 0) : _a(a), m_a(a) {} 
    int _a,m_a;

    A& operator+(const A& t)
    {
        this->m_a = this->m_a * t.m_a; 

        return *this;
    }

    int& operator*() {
        return _a;
    }

    std::ostream& operator<<(ostream& os)
    {
        os << _a;
        return os;
    }

    std::istream& operator>>(istream& is)
    {
        is >> _a;
        return is;
    }
};

std::ostream& operator<<(ostream& os, const A& t)
{
    os << t._a;
    return os;
}

std::istream& operator>>(istream& is, A& t)
{
    is >> t._a;
    return is;
}

int main() {
    A a(2); 
    A b(3); 
    A c(4); 

    cout << "类外调用输入前a= " << a << endl;
    cin >> a;
    cout << "类外调用输入后a= " << a << endl;

    cout << "类内调用输入前b= ";
    b.operator<<(cout);
    cout << endl;
    b.operator>>(cin);
    cout << "类内调用输入后b= ";
    b.operator<<(cout);

    
    cout << endl;

    A* ptr = &a;
    cout << "解引用运算符:a= " << *a << endl;

    // 计算 a + b + c，并输出结果
    A d = a + b + c;
    cout << "a + b + c 的结果: " << d.m_a << endl;

    return 0;
}
